<template>
  <el-card class="box-card">
    <div slot="header" style="display: flex;justify-content: center;align-items: center">
      <!--    justify-content: space-between 沿水平方向两端对齐-->
      <!--    align-items: center 垂直方向居中对齐-->
      <span style="color: blue">添加图书</span>
    </div>
    <el-form>
      <el-form-item label="图书名称">
        <el-input v-model="book.bookName"></el-input>
      </el-form-item>
      <el-form-item label="作者名称">
        <el-input v-model="book.writer">请输入作者名称</el-input>
      </el-form-item>
      <el-button type="success" @click="add" >确认添加</el-button>
    </el-form>
    <div>

    </div>
  </el-card>
</template>

<script>
import http from "../../../../springboot_parent/vue_03/src/api/http";
export default {
  name: "EditVue",
  data() {
    return {
      book: {
        bookName: null,
        writer: null
      }
    };
  },
  methods: {
    add() {
     http.post("/book/addBookList", this.book)
          .then((response) => {
              console.log('ok')
            this.$router.go(-1)
          }).catch((error) => {
            console.error(error);
          });


    }
  }
};
</script>

<style scoped>
</style>
